import 'package:eh_mobile/common/style/bny_color.dart';
import 'package:eh_mobile/common/utils/extension.dart';
import 'package:eh_mobile/common/utils/nav_bar_title.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_svg/svg.dart';
import '../../../../common/values/svg_image.dart';
import '../set_up_common_utils.dart';

class SetUpUserPage extends StatefulWidget {
  const SetUpUserPage({super.key});

  @override
  State<SetUpUserPage> createState() => _SetUpUserPageState();
}

class _SetUpUserPageState extends State<SetUpUserPage> {
  @override
  Widget build(BuildContext context) {
    return NavBarTitle(
      name: 'Admin',
      childWidget: Column(
        children: [
          Expanded(
            child: Column(
              children: [severView(), 12.sizedBoxHeight, formatView()],
            ),
          ),
          Container(
            decoration: BoxDecoration(
                color: BnyColor.lightAlpha255WhiteColor,
                borderRadius: BorderRadius.circular(15.r)),
            margin: EdgeInsets.only(
                bottom: ScreenUtil().bottomBarHeight+20.h, left: 12.w, right: 12.w),
            padding: EdgeInsets.symmetric(horizontal: 146.w,vertical: 18.h),
            child: Text(
              '解除绑定',
              style: TextStyle(
                fontSize: 18.sp,
                color: const Color.fromRGBO(250, 109, 90, 1.0),
              ),
            ),
          )
        ],
      ),
    );
  }

  Widget severView() {
    return SetUpCommonUtils.helpManageView(
      childWidget: Column(
        children: [
          _buildClickCard('服务器', 'ZLHome'),
          SetUpCommonUtils.lineGrayView(),
          _buildClickCard('链接方式', '局域网'),
          SetUpCommonUtils.lineGrayView(),
          _buildClickCard('系统版本', '2023.0815.355'),
        ],
      ),
    );
  }

  // 创建可点击卡片item
  Widget _buildClickCard(String leftName, String content) {
    return Container(
      alignment: Alignment.center,
      padding: const EdgeInsets.fromLTRB(20, 0, 17, 0).r,
      height: 60.r,
      child: Row(
        crossAxisAlignment: CrossAxisAlignment.center,
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        children: [
          Text(leftName, style: SetUpCommonUtils.leftTextStyle),
          Text(content, style: SetUpCommonUtils.rightTextStyle),
        ],
      ),
    );
  }

  Widget formatView() {
    return SetUpCommonUtils.helpManageView(
      childWidget: Column(
        children: [
          _buildClickFormatCard('名称', '局域网', SVGImage.listIcArrowSvg),
          SetUpCommonUtils.lineGrayView(),
          _buildClickFormatCard('语言', '简体中文', SVGImage.listIcArrowSvg),
          SetUpCommonUtils.lineGrayView(),
          _buildClickFormatCard(
              '时区', '中国标准时间GMT+08:00', SVGImage.listIcArrowSvg),
          SetUpCommonUtils.lineGrayView(),
          _buildClickFormatCard('时间格式', '24小时制', SVGImage.listIcArrowSvg),
        ],
      ),
    );
  }

// 创建可点击卡片item
  Widget _buildClickFormatCard(
      String title, String content, String rightImageName) {
    return Container(
      alignment: Alignment.center,
      padding: const EdgeInsets.fromLTRB(20, 0, 17, 0).r,
      height: 60.r,
      child: Row(
        crossAxisAlignment: CrossAxisAlignment.center,
        children: [
          Text(
            title,
            style: 18.ts,
          ),
          const Expanded(child: SizedBox()),
          Text(
            content,
            style:
                14.ts.copyWith(color: const Color.fromRGBO(222, 222, 222, 0.7)),
          ),
          12.sizedBoxWidth,
          SizedBox(
            width: 22.r,
            height: 22.r,
            child: SvgPicture.asset(rightImageName),
          ),
        ],
      ),
    );
  }
}
